//发送请求获取所有数据 渲染表格
const tbody = document.querySelector('#shop-tbody')
getData()
function getData(){
    utils.fetch('./api/shop/select.php').then(resp=>{
        if(resp.code === 200){
            //ES6的解构赋值
            const {list} =resp.body
            // const list = resp.body.list
            let html = ''
            list.forEach((shop ,index) => {
               html +=`
                    <tr data-id="${shop.id}">
                        <th>${index+1}</th>
                        <th><span>${shop.name}</span><input class="inputName" type="text"></th>
                        <th><span>${shop.price}</span><input class="inputPrice" type="text"></th>
                        <th><span>${shop.num}</span><input class="inputNum type="text"></th>
                        <th>
                            <button class="btn btn-info btn-primary btn-xs btn-edit">编辑</button>
                            <button class="btn btn-danger btn-primary btn-xs btn-del">删除</button>
                            <button class="btn btn-success btn-primary btn-xs btn-ok">确定</button>
                            <button class="btn btn-warning btn-primary btn-xs btn-cancel">取消</button>
                        </th>
                    </tr>
               ` 
            })
            tbody.innerHTML =html
        }
    })
}

    

